from typing import Dict, Any, Callable
import json

class Tool:
    def __init__(self, name:str, description:str, parameters:Dict, execute:Callable):
        self.name = name
        self.description = description
        self.parameters = parameters
        self.execute = execute

    def toDict(self) -> Dict:
        return {
            "name":self.name,
            "description":self.description,
            "parameters":json.dumps(self.parameters, ensure_ascii=False)
        }
    
    def execute(self, arguments:Dict) -> Dict[str, Any]:
        return self.execute(arguments)